package com.spring.service.person.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.spring.web.formbean.person.PersonAttentForm;
import com.spring.bean.person.PersonAttent;
import com.spring.dao.person.PersonAttentDao;
import com.spring.bean.page.Page;
import com.spring.bean.page.PageView;
import com.spring.service.ServiceSupport;
import com.spring.service.person.PersonAttentService;
import com.spring.exception.ServiceException;

@Service
@Transactional
public class PersonAttentServiceImpl extends ServiceSupport implements PersonAttentService {

	@Autowired
	private PersonAttentDao personAttentDao;

	/** insert */
	public boolean insert(PersonAttentForm personAttentForm) throws ServiceException {
		try{
			PersonAttent personAttent = formToEntity(PersonAttent.class, personAttentForm);
			return personAttentDao.insert(personAttent);
		} catch (Exception e) {
			throw new ServiceException("PersonAttent --- insert error", e);
		}
	}

	/** update */
	public boolean update(PersonAttentForm personAttentForm) throws ServiceException {
		try{
			PersonAttent personAttent = formToEntity(PersonAttent.class, personAttentForm);
			return personAttentDao.update(personAttent);
		} catch (Exception e) {
			throw new ServiceException("PersonAttent --- update error", e);
		}
	}

	/** delete */
	public boolean delete(Integer id) throws ServiceException {
		try{
			return personAttentDao.delete(id);
		} catch (Exception e) {
			throw new ServiceException("PersonAttent --- delete error", e);
		}
	}

	/** getById */
	public PersonAttent getById(Integer id) throws ServiceException {
		try{
			return personAttentDao.getById(id);
		} catch (Exception e) {
			throw new ServiceException("PersonAttent --- query by id error", e);
		}
	}

	/** queryForList */
	public List<PersonAttent> queryForList() throws ServiceException {
		try{
			return personAttentDao.queryForList();
		} catch (Exception e) {
			throw new ServiceException("PersonAttent --- query list error", e);
		}
	}

	/** queryForPage */
	public PageView<PersonAttent> queryForPage(Page page) throws ServiceException {
		try{
			return personAttentDao.queryForPage(page);
		} catch (Exception e) {
			throw new ServiceException("PersonAttentForm ---query page error", e);
		}
	}
}